package com.siwei.mes.entity.experiment.flyAsk;

import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.util.JsonUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

/**
 * @Description: 粉煤灰-需水量比
 * @Version: 1.0
 * @author: YANGKE
 * @date: 2024/02/25 21:29
 */
@Data
@Accessors(chain = true)
public class FlyAskXslb {
    @ApiModelProperty(value = "胶砂流动度1")
    private String jsldd1 = "";
    @ApiModelProperty(value = "胶砂流动度1平均值")
    private String jsldd1pjz = "";
    @ApiModelProperty(value = "对比胶砂流动度1")
    private String dbjsldd1 = "";
    @ApiModelProperty(value = "胶砂流动度2")
    private String jsldd2 = "";
    @ApiModelProperty(value = "胶砂流动度2平均值")
    private String jsldd2pjz = "";
    @ApiModelProperty(value = "对比胶砂流动度2")
    private String dbjsldd2 = "";
    @ApiModelProperty(value = "粉煤灰需水量")
    private String fmhxsl = "";
    @ApiModelProperty(value = "水泥需水量")
    private String snxsl = "";
    @ApiModelProperty(value = "需水量比")//1
    private String xslb = "";
    @ApiModelProperty(value = "单项结论")//1
    private String dxjl = "";
    @ApiModelProperty(value = "检测日期")
    private String jcrq = "";

    /**
     * 字符串转成对象 然后再转成json
     *
     * @param object
     * @return
     */
    private static JSONObject toJsonObject(Object object) {
        FlyAskXslb entity = new FlyAskXslb();
        if (object == null) {
            return JsonUtils.beanToObject(entity);
        }
        if (object instanceof String) {
            entity = JsonUtils.getObject((String) object, FlyAskXslb.class);
        } else if (object instanceof JSONObject) {
            entity = JsonUtils.getObject((JSONObject) object, FlyAskXslb.class);
        }
        return JsonUtils.beanToObject(entity);
    }

    public static String checkIsMust(JSONObject objJson, String name) {
        if (objJson.isEmpty()) {
            return null;
        }
        FlyAskXslb entity = JsonUtils.getObject(objJson, FlyAskXslb.class);
        if (entity == null) {
            return "存在必检项(" + name + ")未检测，请先检测！";
        }
        if (StringUtils.isBlank(entity.getXslb()) || "null".equals(entity.getXslb())) {
            return "存在必检项(" + name + ")未检测，请先检测！";
        }
        //2024-09-03 10:48:32  李总说不校验
        //if (StringUtils.isBlank(entity.getDxjl()) || "null".equals(entity.getDxjl())) {
        //    return "存在必检项(" + name + ")未检测，请先检测！";
        //}
        return null;
    }
}
